[id].vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <!-- <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1> -->
  6. <!-- 头部 -->
  7. <templateHead v-if="skinId <= 4"></templateHead>
  8. <!-- 皮肤5头部 -->
  9. <templateHead5 v-if="skinId == 5"></templateHead5>
  10. <!-- 皮肤6头部 -->
  11. <templateHead6 v-if="skinId == 6"></templateHead6>
  12. <!-- 菜单 -->
  13. <templateMenu v-if="skinId <= 4"></templateMenu>
  14. <!-- 皮肤5菜单 -->
  15. <templateMenu5 v-if="skinId >= 5"></templateMenu5>
  16. <!-- 商圈详情 -->
  17. <div class="topicInfoBox">
  18. <div class="inner">
  19. <!-- 详情头部 -->
  20. <div class="infoHead">
  21. <div class="left">
  22. <div class="userInfo left">
  23. <el-badge value="楼主" class="item" type="warning">
  24. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  25. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  26. alt="">
  27. </el-badge>
  28. <span>{{ dataInfo.nickname }}</span>
  29. </div>
  30. <div class="headContent left">
  31. <h2>{{ dataInfo.title }}</h2>
  32. <p v-show="dataInfo.group_name">
  33. 群聊:
  34. <span>{{ dataInfo.group_name }}</span>
  35. <button @click="joinGroup">加入群聊</button>
  36. </p>
  37. </div>
  38. </div>
  39. <div class="right">
  40. <div class="one">
  41. <span v-for="item in typeList" :key="index">
  42. <span v-if="dataInfo.type == item.value" class="one">{{ item.label }}</span>
  43. </span>
  44. </div>
  45. <p>{{ dataInfo.updated_at }}</p>
  46. </div>
  47. </div>
  48. <!-- 详情页 文本+图片 -->
  49. <div class="infoContent" v-show="dataInfo.content">
  50. <div v-html="dataInfo.content"></div>
  51. </div>
  52. <div class="infoContent1" v-show="!dataInfo.content">
  53. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  54. <span>可以看看大家的互动哦~</span>
  55. </div>
  56. <!-- 详情页评论 -->
  57. <div class="comment">
  58. <h3>评论</h3>
  59. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  60. <div class="left">
  61. <img v-if='item.avatar' :src="item.avatar" alt="">
  62. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  63. <span class="name">{{ item.nickname }} : </span>
  64. </div>
  65. <div class="center">
  66. <span class="context">{{ item.content }}</span>
  67. </div>
  68. <div class="right">
  69. <span class="time">{{ item.created_at }}</span>
  70. <!-- <span>回复</span> -->
  71. </div>
  72. </div>
  73. <div class="comment_empty" v-show="page_total == 0">
  74. <img src="../../public/topic/message_empty.png" alt="">
  75. <span>暂无评论</span>
  76. </div>
  77. </div>
  78. <!-- 分页 -->
  79. <div class="paginationBox" v-show="page_total != 0">
  80. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  81. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  82. </div>
  83. </div>
  84. </div>
  85. <div class="message">
  86. <div class="inner">
  87. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  88. <button class="btn" @click="addReply">确定</button>
  89. </div>
  90. </div>
  91. <!-- 页面底部 -->
  92. <!-- <HomeFoot1></HomeFoot1> -->
  93. <templateFoot v-if="skinId <= 4"></templateFoot>
  94. <!-- 皮肤5底部 -->
  95. <templateFoot1 v-if="skinId >= 5"></templateFoot1>
  96. </div>
  97. </template>
  98. <script setup>
  99. //1.引用模块 start ---------------------------------------->
  100. //使用ref和reactive动态变量
  101. import { ref, reactive, onMounted } from 'vue'
  102. import { useRoute } from 'vue-router';
  103. //使用官方ssr请求模块
  104. import { useNuxtApp, useFetch } from '#app'
  105. //使用element-plus组件
  106. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  107. // axios请求
  108. const nuxtApp = useNuxtApp();
  109. const axios = nuxtApp.$axios;
  110. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  111. //1.引用模块 end ---------------------------------------->
  112. // 定义响应式数据
  113. const seoData = ref({
  114. title: '商圈',
  115. description: '默认描述',
  116. keywords: '默认关键词',
  117. image: 'https://example.com/default-image.jpg'
  118. });
  119. // 在 onMounted 钩子中获取数据
  120. onMounted(() => {
  121. seoData.value.title = '商圈';
  122. seoData.value.description = '默认描述';
  123. seoData.value.keywords = '默认关键词';
  124. })
  125. //2.页面数据 start ---------------------------------------->
  126. const dataInfo = ref({})
  127. const groupId = useState("groupId", () => '')
  128. const replyList = useState("replyList", () => []) //评论列表
  129. //分页
  130. const page = ref(1)
  131. const pageSize = ref(5)
  132. let page_total = ref(0)
  133. const content = ref('')
  134. //2.页面数据 end ---------------------------------------->
  135. //3.获取商圈详情 start ---------------------------------------->
  136. const route = useRoute();
  137. const id = route.params.id; // 获取传递的 id 参数
  138. //页码发生改变
  139. const changePage = (val) => {
  140. console.log(val);
  141. page.value = val
  142. getTopicReply()
  143. }
  144. // 商圈信息
  145. const getTopicInfo = () => {
  146. let data = new FormData()
  147. data.append('id', id)
  148. axios.post('chat/getTopicInfo', data).then(res => {
  149. console.log('商圈信息', res);
  150. dataInfo.value = res.data
  151. groupId.value = res.data.group_id
  152. console.log(groupId.value);
  153. })
  154. }
  155. // 回复商圈 列表
  156. const getTopicReply = () => {
  157. let data = new FormData()
  158. data.append('id', id)
  159. data.append('page', page.value)
  160. data.append('page_size', pageSize.value)
  161. axios.post('chat/getTopicReply', data).then(res => {
  162. console.log('回复商圈列表 ', res);
  163. replyList.value = res.data.data
  164. // page_total.value = res.data.total
  165. page_total.value = res.data.total
  166. console.log("replyList", replyList);
  167. })
  168. }
  169. //5.获取分类和状态 start ---------------------------------------->
  170. const listData = useState("listData", () => [])//商圈列表
  171. const typeList = useState("typeList", () => [])//商圈分类
  172. const topicType = () => {
  173. axios.post('/chat/topicType').then(response => {
  174. console.log(111222333)
  175. console.log(response.data);
  176. // console.log(1);
  177. typeList.value = response.data;
  178. })
  179. }
  180. const topicStatus = () => {
  181. axios.post('chat/topicStatus').then(response => {
  182. console.log(response);
  183. })
  184. }
  185. onMounted(() => {
  186. getTopicInfo(); //商圈信息
  187. getTopicReply(); //回复商圈列表
  188. topicType();
  189. topicStatus();
  190. })
  191. //加入群聊
  192. const joinGroup = () => {
  193. ElMessageBox.confirm(
  194. '加入群聊后,页面跳转至后台群聊页面',
  195. '是否加入群聊?',
  196. {
  197. confirmButtonText: '是',
  198. cancelButtonText: '否',
  199. center: true,
  200. }
  201. ).then(() => {
  202. console.log('groupId.value', groupId.value);
  203. let data = new FormData()
  204. data.append('group_id', groupId.value)
  205. axios.post('chat/joinGroup', data).then(res => {
  206. console.log('加入群聊 ', res);
  207. if (res.code == 0 && res.message !== '已加入群') {
  208. ElMessage.error(res.message)
  209. } else if (res.code == 0 && res.message == '已加入群') {
  210. ElMessage({
  211. message: res.message,
  212. type: 'success',
  213. })
  214. setTimeout(() => {
  215. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  216. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  217. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  218. }, 1000)
  219. } else if (res.code == 200) {
  220. ElMessage({
  221. message: '加入成功',
  222. type: 'success',
  223. })
  224. setTimeout(() => {
  225. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  226. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  227. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  228. }, 1000)
  229. }
  230. })
  231. }).catch(() => {
  232. ElMessage({
  233. type: 'error',
  234. message: '已取消',
  235. })
  236. })
  237. }
  238. // 回复商圈
  239. const addReply = () => {
  240. let data = new FormData()
  241. data.append('id', id)
  242. data.append('content', content.value)
  243. axios.post('chat/addReply', data).then(res => {
  244. console.log('回复商圈 ', res);
  245. if (res.code == 0) {
  246. ElMessage.error(res.message)
  247. getTopicReply();
  248. } else if (res.code == 200) {
  249. ElMessage({
  250. message: '回复成功',
  251. type: 'success',
  252. })
  253. content.value = ''
  254. getTopicReply();
  255. }
  256. })
  257. }
  258. //3.获取商圈详情 end ---------------------------------------->
  259. //自助建站 start---------------------------------------->
  260. //1.获得自助建站头部底部
  261. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  262. import templateHead5 from '@/components/template/sector/head/1200x250/1.vue'
  263. import templateHead6 from '@/components/template/sector/head/1200x250/6.vue'
  264. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  265. import templateMenu5 from '@/components/template/sector/menu/1200x187/1.vue'
  266. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  267. import templateFoot1 from '@/components/template/sector/foot/1200x680/1.vue'
  268. //2.获得pinia源
  269. import { useTemplateBaseStore } from '@/stores/templateBase'
  270. const templateBaseStore = useTemplateBaseStore()
  271. //3.获得该页的皮肤id
  272. const skinId = ref("")
  273. const websiteId = ref("")
  274. //4.获得站点基本信息
  275. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  276. method: 'GET',
  277. query: {
  278. 'link_textnum': 24,
  279. 'link_imgnum': 18,
  280. 'link_footnum': 4
  281. },
  282. });
  283. if (responseStatus.code == 200) {
  284. if (responseStatus.data.website_foot.foot_info.status == 1) {
  285. //网站模板已停用,直接转入404页面
  286. navigateTo('/error?findPage=index')
  287. } else {
  288. //4.1设置站点基本信息
  289. templateBaseStore.setWebSiteInfo(responseStatus.data)
  290. websiteId.value = responseStatus.data.website_head.id;
  291. //4.2设置皮肤id
  292. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  293. //4.3设置seo
  294. useSeoMeta({
  295. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  296. meta: [
  297. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  298. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 }
  299. ]
  300. });
  301. }
  302. }
  303. //5.获得广告池
  304. const adData = ref([]);
  305. const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
  306. method: 'GET',
  307. query: {},
  308. });
  309. if (adResponseStatus.code == 200) {
  310. templateBaseStore.setAdList(adResponseStatus.data)
  311. adData.value = adResponseStatus.data;
  312. }
  313. //6.是否使用了搜索页
  314. const response = await requestDataPromise('/client/indexData', {
  315. method: 'POST',
  316. body: {
  317. 'website_id': websiteId.value,
  318. 'getpage': 'article'
  319. },
  320. });
  321. if (response.code == 200) {
  322. //是否启用搜索功能
  323. templateBaseStore.setIsSearch(response.data.isSearch)
  324. }
  325. //自助建站 end---------------------------------------->
  326. </script>
  327. <style lang="less" scoped>
  328. .topicInfoBox {
  329. .inner {
  330. width: 1200px;
  331. margin: 0 auto;
  332. //信息头部
  333. .infoHead {
  334. height: 200px;
  335. padding: 65px 0 60px 40px;
  336. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  337. box-sizing: border-box;
  338. >.left {
  339. .userInfo {
  340. margin-right: 90px;
  341. .item {
  342. margin-top: -5px;
  343. margin-right: -5px;
  344. :deep(.el-badge__content.is-fixed) {
  345. position: absolute;
  346. right: calc(1px + var(--el-badge-size) / 2);
  347. top: 0;
  348. transform: translateY(-31%) translateX(79%);
  349. z-index: var(--el-index-normal);
  350. }
  351. img {
  352. width: 66px;
  353. height: 66px;
  354. vertical-align: middle;
  355. border-radius: 50%;
  356. }
  357. }
  358. span {
  359. margin-left: 15px;
  360. font-family: Microsoft YaHei, Microsoft YaHei;
  361. font-weight: 400;
  362. font-size: 18px;
  363. color: #333333;
  364. }
  365. }
  366. .headContent {
  367. h2 {
  368. width: 750px;
  369. height: 56px;
  370. line-height: 28px;
  371. display: -webkit-box;
  372. -webkit-box-orient: vertical;
  373. -webkit-line-clamp: 2;
  374. overflow: hidden;
  375. text-overflow: ellipsis;
  376. word-break: break-all;
  377. font-family: Microsoft YaHei, Microsoft YaHei;
  378. font-weight: bold;
  379. font-size: 20px;
  380. color: #333333;
  381. margin-bottom: 26px;
  382. }
  383. >p {
  384. font-family: Microsoft YaHei, Microsoft YaHei;
  385. font-weight: 400;
  386. font-size: 16px;
  387. color: #333333;
  388. button {
  389. width: 86px;
  390. height: 32px;
  391. background-color: #028e21;
  392. color: #fff;
  393. border: none;
  394. margin-left: 100px;
  395. }
  396. }
  397. }
  398. }
  399. >.right {
  400. position: relative;
  401. div {
  402. position: absolute;
  403. right: 0;
  404. top: 0;
  405. width: 71px;
  406. height: 32px;
  407. line-height: 32px;
  408. text-align: center;
  409. background-color: #d9f0d6;
  410. margin-bottom: 29px;
  411. font-family: Microsoft YaHei, Microsoft YaHei;
  412. font-weight: 400;
  413. font-size: 16px;
  414. color: #33B023;
  415. }
  416. .one {
  417. color: #FFAA33;
  418. background-color: #fbebd5;
  419. }
  420. .two {
  421. color: #33B023;
  422. background-color: #d5ecd2;
  423. }
  424. .three {
  425. color: #666;
  426. background-color: #ebebeb;
  427. }
  428. p {
  429. width: 150px;
  430. text-align: right;
  431. position: absolute;
  432. top: 62px;
  433. right: 0;
  434. }
  435. }
  436. }
  437. // 有详情信息
  438. .infoContent {
  439. width: 1196px;
  440. overflow: hidden;
  441. padding: 30px 46px;
  442. font-family: Microsoft YaHei, Microsoft YaHei;
  443. font-size: 20px;
  444. line-height: 40px;
  445. box-sizing: border-box;
  446. div {
  447. word-wrap: break-word;
  448. /* 强制长单词或 URL 换行 */
  449. overflow-wrap: break-word;
  450. /* 现代推荐用法,等同于 word-wrap */
  451. white-space: pre-wrap;
  452. /* 保留空白字符并允许自动换行 */
  453. word-break: break-all;
  454. /* 强制在任意字符处换行 */
  455. }
  456. }
  457. .leftBottom::v-deep p {
  458. width: 1200px;
  459. white-space: pre-wrap;
  460. }
  461. //没有详情信息
  462. .comment_empty,
  463. .infoContent1 {
  464. height: 300px;
  465. line-height: 260px;
  466. text-align: center;
  467. img {
  468. width: 78px;
  469. height: 78px;
  470. vertical-align: -25px;
  471. vertical-align: middle;
  472. margin-right: 20px;
  473. }
  474. span {
  475. font-family: Microsoft YaHei, Microsoft YaHei;
  476. font-weight: bold;
  477. font-size: 26px;
  478. color: #CCCCCC;
  479. }
  480. }
  481. //评论
  482. .comment {
  483. h3 {
  484. height: 100px;
  485. padding-top: 30px;
  486. box-sizing: border-box;
  487. border-bottom: 1px solid #E1E1E1;
  488. font-family: Microsoft YaHei, Microsoft YaHei;
  489. font-weight: 400;
  490. font-size: 22px;
  491. color: #000000;
  492. }
  493. .commentList {
  494. border: 1px solid #E1E1E1;
  495. background-color: #fafafa;
  496. margin-top: 20px;
  497. padding: 30px 30px;
  498. box-sizing: border-box;
  499. display: flex;
  500. align-items: flex-start;
  501. justify-content: space-between;
  502. .left {
  503. width: 400px;
  504. margin-right: 30px;
  505. display: flex;
  506. justify-content: space-between;
  507. img {
  508. width: 52px;
  509. height: 52px;
  510. border-radius: 50%;
  511. vertical-align: middle;
  512. margin-right: 15px;
  513. }
  514. span {
  515. height: 52px;
  516. line-height: 22px;
  517. padding-top: 10px;
  518. }
  519. .name {
  520. width: 120px;
  521. font-family: Microsoft YaHei, Microsoft YaHei;
  522. font-weight: 400;
  523. font-size: 16px;
  524. color: #333333;
  525. margin-right: 15px;
  526. white-space: nowrap;
  527. overflow: hidden;
  528. text-overflow: ellipsis;
  529. display: block;
  530. }
  531. }
  532. .center {
  533. .context {
  534. width: 700px;
  535. margin-right: 40px;
  536. display: -webkit-box;
  537. -webkit-box-orient: vertical;
  538. -webkit-line-clamp: 2;
  539. overflow: hidden;
  540. text-overflow: ellipsis;
  541. word-break: break-all;
  542. font-family: Microsoft YaHei, Microsoft YaHei;
  543. font-weight: bold;
  544. font-size: 16px;
  545. color: #333333;
  546. }
  547. }
  548. .right {
  549. .time {
  550. display: block;
  551. width: 200px;
  552. font-family: Microsoft YaHei, Microsoft YaHei;
  553. font-weight: 400;
  554. font-size: 16px;
  555. color: #999999;
  556. margin-right: 30px;
  557. }
  558. span {
  559. font-family: Microsoft YaHei, Microsoft YaHei;
  560. font-weight: 400;
  561. font-size: 16px;
  562. color: #333333;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. }
  569. //评论回复
  570. .message {
  571. width: 1200px;
  572. margin: 0 auto 20px;
  573. padding: 0px 25px;
  574. box-sizing: border-box;
  575. height: 145px;
  576. line-height: 145px;
  577. background-color: #ecf5ee;
  578. .inner {
  579. .messageInput {
  580. width: 1000px;
  581. height: 67px;
  582. outline: none;
  583. border: 1px solid #E1E1E1;
  584. background-color: #fafafa;
  585. font-family: Microsoft YaHei, Microsoft YaHei;
  586. font-weight: 400;
  587. font-size: 18px;
  588. color: #666;
  589. padding: 0 20px;
  590. box-sizing: border-box;
  591. }
  592. .btn {
  593. width: 115px;
  594. height: 40px;
  595. border: none;
  596. background-color: #028e21;
  597. color: #fff;
  598. border-radius: 6px;
  599. margin-left: 36px;
  600. font-family: Microsoft YaHei, Microsoft YaHei;
  601. font-weight: 400;
  602. font-size: 16px;
  603. }
  604. }
  605. }
  606. //分页
  607. .paginationBox {
  608. display: flex;
  609. justify-content: center;
  610. margin-top: 60px;
  611. margin-bottom: 90px;
  612. // 鼠标移入后字体颜色
  613. :deep(.el-pagination:hover) {
  614. color: #139609;
  615. }
  616. :deep(.el-pagination.is-background .btn-next),
  617. :deep(.el-pagination.is-background .btn-prev) {
  618. width: 70px;
  619. height: 34px;
  620. margin: 0px 10px;
  621. border-radius: 4px;
  622. }
  623. :deep(.el-pagination.is-background .el-pager li) {
  624. margin: 0px 10px;
  625. width: 38px;
  626. height: 34px;
  627. border-radius: 4px;
  628. }
  629. :deep(.el-pagination.is-background .btn-next.is-active),
  630. :deep(.el-pagination.is-background .btn-prev.is-active),
  631. :deep(.el-pagination.is-background .el-pager li.is-active) {
  632. background-color: #028e21;
  633. color: #fff;
  634. }
  635. }
  636. </style>